<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 实现arr[Symbol.iterator]()
      function myIterator(arr) {
        var num = 0;
        return {
          next() {
            return {
              done: num >= arr.length ? true : false,
              value: arr[num++],
            };
          },
        };
      }

      var arr = ["张三", "李四", "王五"];
      let newArr = myIterator(arr);
      //var myIterator = arr[Symbol.iterator]();
      //myIterator(arr)= arr[Symbol.iterator]();
      console.log(newArr.next());
      console.log(newArr.next());
      console.log(newArr.next());
      console.log(newArr.next());
    </script>
  </body>
</html>
